<template>
  <div class="charts">
    <v-chart :option="getOptions()"></v-chart>
  </div>
</template>

<script setup lang="ts">
//引入echarts
import * as echarts from "echarts";
const getOptions = () => {
  return {
    xAxis: {
      type: "category",
      show: false,
      boundaryGap: false,
    },
    yAxis: {
      show: false,
    },
    series: {
      type: "line",
      data: props.data,
      itemStyle: {
        opacity: 0,
      },
      smooth: true,
      areaStyle: {
        color: "pink",
      },
      lineStyle: {
        opacity: 0,
      },
      cursor: "pointer",

      label: {
        show: true,
        position: "top",
      },
    },
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
    tooltip: {
      trigger: "axis",
      //限制展示区域，在容器内部
      confine: true,
    },
  };
};

// 接收父组件传递过来的数据,只有在模板中才能直接用,在js中需要一个变量来接收
let props = defineProps(["data"]);
</script>

<style scoped>
.charts {
  width: 100%;
  height: 100%;
  padding-bottom: 10px;
}
</style>